﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace SopcInfo
{
    public class SopcParser
    {
        public void Parer(string path)
        {
            var xdoc = XDocument.Load(path);
            var nodes = xdoc.Descendants();
            foreach (var node in nodes)
            {
                if (node.Name == "interface" && node.Attribute("name").Value == "bar1_0")
                {
                    var nodesDesc = node.Descendants();

                    foreach (var item in nodesDesc)
                    {
                        if (item.Name == "memoryBlock")
                        {
                            Console.WriteLine(item.Name);
                            Console.WriteLine("     Name: " + item.Elements("moduleName").Single().Value);
                            Console.WriteLine("     Base: " + item.Elements("baseAddress").Single().Value);
                            Console.WriteLine("     Span: " + item.Elements("span").Single().Value);
                        }
                    }
                }
                    
            }
        }
    }
}
